package cn.bdqn.controller;

import cn.bdqn.domain.Driver;
import cn.bdqn.domain.Routes;
import cn.bdqn.domain.Vehicle;
import cn.bdqn.service.VehicleDriverService;
import cn.bdqn.utils.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author dkj
 */
@RestController
public class VehicleDriverController {

    @Autowired
    private VehicleDriverService vehicleDriverService;


    /**
     * 根据id查询
     * @param id
     * @return
     */
    // ------------------- 服务熔断-----------------
    @GetMapping(value = "/driver/queryByPrimaryKey/{id}")
    public Result queryDriverByPrimaryKey(@PathVariable("id") Integer id){
        return vehicleDriverService.queryDriverByPrimaryKey(id);
    }

    /**
     * 选择更新信息
     * @param driver
     */
    // ------------------- 服务熔断-----------------
    @RequestMapping(value = "/driver/updateByPrimaryKeySelective/driver")
    public Result updateByPrimaryKeySelective(Driver driver){
        return vehicleDriverService.updateByPrimaryKeySelective(driver);
    }

    /**
     * 多条件查询   分页
     * @param driver
     * @return
     */
    // ------------------- 服务熔断-----------------
    @GetMapping(value = "/driver/queryByDriver/driver/pageNum/{pageNum}/pageAmount/{pageAmount}")
    public Result queryByDriver(Driver driver,@PathVariable("pageNum") Integer pageNum,@PathVariable("pageAmount") Integer pageAmount){
        return vehicleDriverService.queryByDriver(driver, pageNum, pageAmount);
    }


//    **********************路线****************************


    /**
     * 根据id查询
     * @param id
     * @return
     */
    // ------------------- 服务熔断-----------------
    @GetMapping(value = "/driver/routes/queryByPrimaryKey/{id}")
    public Result queryRoutesByPrimaryKey(@PathVariable("id") Integer id){
        return vehicleDriverService.queryRoutesByPrimaryKey(id);
    }

    /**
     * 选择更新
     * @param record
     */
    // ------------------- 服务熔断-----------------
    @RequestMapping(value = "/driver/routes/updateByPrimaryKeySelective/record")
    public Result updateByPrimaryKeySelective(Routes record){
        return vehicleDriverService.updateByPrimaryKeySelective(record);
    }

    /**
     * 多条件查询   分页
     * @param routes
     * @return
     */
    // ------------------- 服务熔断-----------------
    @GetMapping(value = "/driver/routes/queryByVehicle/Routes/pageNum/{pageNum}/pageAmount/{pageAmount}")
    public Result queryByVehicle(Routes routes,@PathVariable("pageNum") Integer pageNum,@PathVariable("pageAmount") Integer pageAmount){
        return vehicleDriverService.queryByVehicle(routes, pageNum, pageAmount);
    }


    //*******************车辆******************

    /**
     * 根据id查询
     * @param id
     * @return
     **/
    // ------------------- 服务熔断-----------------
    @GetMapping(value = "/driver/vehicle/queryByPrimaryKey/{id}")
    public Result queryVehicleByPrimaryKey(@PathVariable("id") Integer id){
        return vehicleDriverService.queryVehicleByPrimaryKey(id);
    }


    /**
     * 选择更新
     * @param record
     */
    // ------------------- 服务熔断-----------------
    @RequestMapping(value = "/driver/vehicle/updateByPrimaryKeySelective/record")
    public Result updateByPrimaryKeySelective(Vehicle record){
        return vehicleDriverService.updateByPrimaryKeySelective(record);
    }

    /**
     * 新增
     * @param record
     */
    // ------------------- 服务熔断-----------------
    @RequestMapping(value = "/driver/vehicle/insert/record")
    public Result insert(Vehicle record){
        return vehicleDriverService.insert(record);
    }

    /**
     * 多条件查询   分页
     *
     * @param pageNum   当前页
     * @param pageAmount    每页显示的页数
     * @return
     */
    // ------------------- 服务熔断-----------------
    @PostMapping(value = "/driver/vehicle/queryByVehicle/vehicle/pageNum/{pageNum}/pageAmount/{pageAmount}")
    public Result queryByVehicle(Vehicle vehicle,@PathVariable("pageNum") Integer pageNum,@PathVariable("pageAmount") Integer pageAmount){
        return vehicleDriverService.queryByVehicle(vehicle, pageNum, pageAmount);
    }

}
